<div id="content">

    <section class="row">


        <div class="span-left">
            
            <h1><?=$h1_title?></h1>

            <div id="results" >

                <div class="page_navigation" id="fix_top_pager_nav"></div>

                <div class="box clearfix pager_hold" id="pager_hold">

                    <div class="col">

                        <label><?= lang('hotell.sort_by_upper') ?></label>
                        <div class="input-half">
                            <select name="sort_by" id="sort_by" class="dropdownized">
                                <option value="recommended"><?= lang('recommended') ?></option>
                                <? if (!isset($_GET['preview'])): ?>
                                <option value="price"><?= lang('price') ?></option>
                                <? endif; ?>
                                <option value="number_of_stars"><?= lang('filter.stars') ?></option>
                                <!--<option value="object_name">Name</option>-->
                            </select>
                        </div>

                    </div>

                </div>

                <ul class="list hotels-list" id="list">
                    <?
                    if (!isset($_GET['preview'])) {

                    $build_G = $_GET;
                    if ($build_G['dest_hot'] == "")
                    $build_G['dest_hot'] = -1;

                    unset($build_G['lang']);

                    $build_GET = http_build_query($build_G);

                    $price_for_no_days = calculateDays($_GET['check_in'], $_GET['check_out'], TRUE);

                    $night_s = $price_for_no_days > 1 ? lang('res.nights') : lang('res.night');
                    } else {
                    $build_GET = '&preview=1';
                    }


                    $rows = $results;

                    $cnt = count($rows);
                    for ($i = 0; $i < $cnt; $i++):
                    $obj_name = URLify::filter($rows[$i]->object_name);

                    $href = lang_url('accommodation/' . $obj_name . '-' . $rows[$i]->object_ID . '?' . $build_GET . '&room_id=' . $rows[$i]->rooms[0]->room_ID);

                    $thumbnail = HOST_URL_HOTELS . 'gallery/' . $rows[$i]->photo_path . '/thumb_187x140/' . $rows[$i]->photo_name;
                    $preview = HOST_URL_HOTELS . 'gallery/' . $rows[$i]->photo_path . '/thumb_454x340/' . $rows[$i]->photo_name;


                    $stars = (int)$rows[$i]->object_number_of_stars;
                    ?>

                    <li class="js_item box list" id="box-<?= $rows[$i]->object_ID ?>" style="display: block" data-id="<?= $rows[$i]->object_ID ?>">

                        <div class="title clearfix">

                            <? if ($stars > 0): ?>
                            <div class="stars small yelow star-<?= $stars ?>"></div>
                            <? endif; ?>

                            <h2><a href="<?= $href ?>"><?= $rows[$i]->object_name ?></a></h2>

                            <? if (isset($results[$i]->object_recommended) && $results[$i]->object_recommended == '1'): ?>
                            <div class="recomended"><?= lang('recommended') ?></div>
                            <? endif; ?>

                        </div>
                        <div class="cont">

                            <div class="clearfix">

                                <div class="right">
                                    <div class="result-price"><span class="from"><?= lang('from'); ?></span> <?= lang(currency_sign()) ?> <?= !isset($_GET['preview']) ? $rows[$i]->rooms[0]->selling_price : $rows[$i]->lowest_price; ?></div>
                                    <a href="<?= $href ?>" class="button small"><?= lang('res.book_now') ?></a>
                                </div>

                                <a href="<?= $href ?>" class="image">
                                    <img src="<?= $thumbnail ?>" alt="<?= $rows[$i]->object_name ?>">
                                </a>

                                <div class="dec">
                                    <div class="loc"><?= $results[$i]->destination_name ?>, <?= lang('montenegro'); ?></div>

                                    <? if (isset($results[$i]->object_x_coordinate) && $results[$i]->object_x_coordinate != "" && isset($results[$i]->object_y_coordinate) && $results[$i]->object_y_coordinate != ""): ?>
                                    <a href='javascript:' class="show_map" data-id="<?= $rows[$i]->object_ID ?>"><?= lang('map.show_on_map') ?></a>
                                    <? endif; ?>

                                    <div class="text"><?= limit_text($rows[$i]->object_info, 90, TRUE, TRUE); ?> </div>
                                </div>

                            </div>

                        </div>

                        <div style="display: block" class="table-holder">

                            <table id="hor-minimalist-b" class="table table-condensed table-hover rooms">
                                <tbody>
                                    <tr>
                                        <th><?= lang('res.accommodation'); ?></th>
                                        <th><?= lang('res.service'); ?></th>
                                        <th>Status</th>
                                        <th><?= lang('res.total_price'); ?></th>
                                    </tr>
                                    <?
                                    foreach ($results[$i]->rooms as $room):
                                    $href_room = lang_url('accommodation/' . $obj_name . '-' . $results[$i]->object_ID . '?' . $build_GET . '&room_id=' . $room->room_ID);
                                    $person_s = $room->room_max_person > 1 ? lang('res.persons') : lang('res.person');

                                    if ($this->lang->mci_current() == 'me'):

                                    if ($room->room_max_person == 1)
                                    $person_s = lang('res.person');
                                    else if ($room->room_max_person >= 2 && $room->room_max_person <= 4)
                                    $person_s = lang('res.persone');
                                    else
                                    $person_s = lang('res.persons');

                                    endif;

                                    ?>
                                    <tr>
                                        <td>
                                            <a href="<?= $href_room ?>"><?= lang('room.' . underscore($room->room_type_name)); ?>
                                                <span
                                                    class="gray"><?= $room->room_description ?></span>&nbsp;<?= lang('form.for'); ?> <?= $room->room_max_person ?> <?= $person_s ?>
                                            </a></td>
                                        <td class="gray"><?= $room->service_name ?></td>

                                        <?
                                        switch ($room->room_selling_type_ID) {
                                        case 1:
                                        ?>
                                        <td class="request">
                                            <?= lang('res.send_request') ?>
                                        </td>
                                        <?
                                        break;

                                        case 2:
                                        ?>
                                        <td class="realtime">
                                            <?= lang('available') ?>
                                        </td><?
                                        break;
                                        };
                                        ?>
                                        <td class="price"><? if (!isset($_GET['preview'])) echo lang(currency_sign())." ".$room->selling_total; ?> </td>


                                    </tr>
                                    <? endforeach; ?>

                                </tbody>
                            </table>

                        </div>

                    </li>

                    <?endfor;?>



                </ul>

            </div>

        </div>

        <div class="span-right">

            <? $this->load->view('parts/form'); ?> 
            <? $this->load->view('parts/show_map'); ?> 
            <? $this->load->view('parts/filter'); ?> 

        </div>
    </section>

</div>